import { WebVariable } from "../../../../../../data/WebVariable";
const getKeyArr = (arr: any, key: string) => {
  let jee: string[] = arr.map((item: any) => {
    return item[key];
  });
  return jee;
};
export const getSchema = (subItem: any[]) => {
  let arrNum: string[] = getKeyArr(WebVariable.categoryType, "key");
  let arrlabel: string[] = getKeyArr(WebVariable.categoryType, "label");
  let subId: string[] = getKeyArr(subItem, "id");
  let subName: string[] = getKeyArr(subItem, "name");
  console.log(subId, subName);
  return {
    type: "object",
    "ui:displayType": "row",
    "ui:showDescIcon": true,
    "ui:column": 1,
    properties: {
      name: {
        title: "名称",
        type: "string",
        "ui:options": {},
      },
      no: {
        title: "编号",
        type: "string",
        "ui:options": {},
      },
      energyType: {
        title: "能源类型",
        type: "string",
        enum: arrNum,
        enumNames: arrlabel,
      },
      deviceTypeId: {
        title: "分项类型",
        type: "string",
        enum: subId,
        enumNames: subName,
      },
      installAddr: {
        title: "说明",
        type: "string",
        format: "textarea",
        "ui:options": {},
      },
    },
    required: ["name", "no", "energyType", "deviceTypeId"],
  };
};
